package com.rockpaperscissorlhh.service;

import com.rockpaperscissorlhh.object.Computer;
import com.rockpaperscissorlhh.object.Person;
import com.rockpaperscissorlhh.result.Result;

import java.util.Random;
import java.util.Scanner;

public class RockpaperscissorImpl implements Rockpaperscissor {

    /***
     * 人:0-输,1-赢，2-和局
     * @param person
     * @param computer
     */
    @Override
    public Result gameStandard(Person person, Computer computer) {
        int run = (person.getHand() - computer.getHand()+3)%3;
        Result result = new Result();
        switch (run) {
            case 0:
                result.setDraws(result.getDraws() + 1);
                break;
            case 1:
                result.setPersonwin(result.getPersonwin()+1);
                break;
            case 2:
                result.setPersonlosses(result.getPersonlosses()+1);
                break;
            case 3:
                result.setComputerwin(result.getComputerwin()+1);
                break;
            case 4:
                result.setComputerlosses(result.getComputerlosses()+1);
                break;
            default:
                break;
        }

        return result;//类返回对象，返回值为null

    }

    /***
     * 人:0-输,1-赢，2-和局
     * @param person
     * @param computer
     */
    @Override
    public int gameStandard(int person, int computer) {
        int a = 2;
        switch (computer) {
            case 0:
                System.out.println("电脑本次出的是石头");
                if (person == 0) {
                    a = 2;
                } else if (person == 1) {
                    a = 1;
                } else if (person == 2) {
                    a = 0;
                }
                break;
            case 1:
                System.out.println("电脑本次出的是布");
                if (person == 1) {
                    a = 2;
                } else if (person == 0) {
                    a = 0;
                } else if (person == 2) {
                    a = 1;
                }
                break;
            case 2:
                System.out.println("电脑本次出的是剪刀");
                if (person == 2) {
                    a = 2;
                } else if (person == 1) {
                    a = 0;
                } else if (person == 0) {
                    a = 1;
                }
                break;
            default:

                break;

        }
        return a;
    }
}